package com.edu.demo.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaCheckRole;
import cn.dev33.satoken.annotation.SaMode;
import com.edu.demo.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 权限
 */
@Api(tags = "权限测试")
@RestController
@RequestMapping("/Privilege")
public class PrivilegeController {

    @ApiOperation(value = "对学生角色的校验")
    @SaCheckRole("student")
    @GetMapping("/test1")
    public Result getTest1(){
        return Result.success("学生才能访问，成功获取到数据");
    }

    @ApiOperation(value = "对老师角色的校验")
    @SaCheckRole("class_teacher")
    @GetMapping("/test2")
    public Result getTest2(){
        return Result.success("老师才能访问，成功获取到数据");
    }

    @ApiOperation(value = "对校长角色的校验")
    @SaCheckRole("principal")
    @GetMapping("/test3")
    public Result getTest3(){
        return Result.success("校长才能访问，成功获取到数据");
    }

    @ApiOperation(value = "对校长或老师角色的校验")
    @SaCheckRole(value = {"class_teacher","principal"},mode = SaMode.OR)
    @GetMapping("/test4")
    public Result getTest4(){
        return Result.success("校长或老师才能访问，成功获取到数据");
    }

    @ApiOperation(value = "对校长和老师角色的校验")
    @SaCheckRole(value = {"class_teacher","principal"},mode = SaMode.AND)
    @GetMapping("/test5")
    public Result getTest5(){
        return Result.success("校长和老师才能访问，成功获取到数据");
    }

    //----------------------------------------权限------------------------------------
    @ApiOperation(value = "学费金额的修改发")
    @SaCheckPermission("tuition.update.money")
   @GetMapping("/test6")
    public Result getTest6(){
        return Result.success("校长和老师才能访问，成功修改金额");
    }
}
